import { reqCategoryData } from '../../api/category'

Page({
  data:{
    categoryList:[], 
    activeIndex:0 
  },
  async getCategoryData(){
    const res = await reqCategoryData()
    // console.log(res.data);
    if(res.code === 200){
      this.setData({
        categoryList:res.data
      })
    }
  },
  updateActive(event){
    const { index } = event.currentTarget.dataset  //解析 index ，也就是获取index
    this.setData({
      activeIndex:index
    })
  },
  onLoad(){
    this.getCategoryData()
  }
})
